package org.jwcloud.project.module.zx.txzldp.controller;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import org.jwcloud.project.module.zx.baseManager.service.repository.MatBaseManagerRepository;
import org.jwcloud.project.module.zx.common.FmtUtil;
import org.jwcloud.project.module.zx.common.Resp;
import org.jwcloud.project.module.zx.common.repository.RptCommonRepository;
import org.jwcloud.project.module.zx.common.service.RptUtService;
import org.jwcloud.project.module.zx.txzldp.service.repository.TxzldpCommonViewRepository;
import org.jwcloud.project.module.zx.txzldp.service.repository.TxzldpDoorRepository;
import org.jwcloud.project.module.zx.workTime.service.repository.MatWorkTimeRepository;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration.WebMvcAutoConfigurationAdapter;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import com.github.pagehelper.PageHelper;
import com.jw.mid.mm.comm.common.controller.BaseController;
import com.jw.mid.mm.comm.common.controller.CrudController;
import com.jw.mid.mm.comm.common.json.Response;
import com.jw.mid.mm.comm.common.pagination.ListBounds;
import com.jw.mid.mm.comm.common.pagination.ListSlice;
import com.jw.mid.mm.comm.common.pagination.PageListSlice;
import com.jw.mid.mm.comm.common.pagination.Pagination;
import com.jw.mid.mm.comm.common.service.CrudService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@Api(value = "API - Controlle",
description = "维护各种汇总数据 年份\r\n" + 
		"核实数量\r\n" + 
		"整改数量\r\n" + 
		"处置人数"
		+ "\\r\\n\\r\\n"
		+ "年份\r\n" + 
		"每年案件数量\r\n" + 
		"公务员涉及案件人数\r\n" + 
		"机关管理人员涉及案件人数\r\n" + 
		"办公人员涉及案件人数\r\n" + 
		"国有企业人员涉及案件人数\r\n" + 
		"基层管理人员涉及案件人数\r\n" + 
		"其他人员涉及案件人数\r\n" + 
		"第一类形态\r\n" + 
		"第二类形态", tags = "door")
@RestController
@Transactional
@RequestMapping("/rest/txzldp/collectMaintenance")
public class TxzldpCollectMaintenanceController extends BaseController{
	
	@Autowired
    private SqlSessionTemplate sqlSessionTemplate;
	
	@Autowired
    public RptUtService rptUtService;
	/**
	 * 问题数量
	 * @param param
	 * @param model
	 * @return
	 */
	@RequestMapping("/questionNum")
	public ModelAndView txzldpDoor(@RequestParam Map param, ModelAndView model) {
		model.setViewName("pages/collectMaintenance/QuestionNum.html");
		return model;
	}
	/**
	 * 案件信息
	 * @param param
	 * @param model
	 * @return
	 */
	@RequestMapping("/ajxx")
	public ModelAndView ajxx(@RequestParam Map param, ModelAndView model) {
		model.setViewName("pages/collectMaintenance/Ajxx.html");
		return model;
	}
	
	@GetMapping("queryQuestionNumList")
    @ApiOperation(value = "", notes = "")
    @ApiImplicitParams({
    })
    public Resp queryQuestionNumList(
    		@RequestParam(required = false) Map<String,String> param
    		){
		return Resp.success(this.sqlSessionTemplate.selectList("txzldp.collectMaintenance.queryQuestionNumList", param));
    }
	
	@PostMapping("insertQuestionNumList")
    @ApiOperation(value = "", notes = "")
    @ApiImplicitParams({
    })
    public Resp insertQuestionNumList(
    		@RequestBody(required = false) Map<String,String> param
    		){
		int num = this.sqlSessionTemplate.insert("txzldp.collectMaintenance.insertQuestionNumList", param);
		if(num == 0) {
			return Resp.error("年份重复");
		}else {
			return Resp.success(num);
		}
    }
	
	@PostMapping("updateQuestionNumList")
    @ApiOperation(value = "", notes = "")
    @ApiImplicitParams({
    })
    public Resp updateQuestionNumList(
    		@RequestBody(required = false) Map<String,String> param
    		){
		return Resp.success(this.sqlSessionTemplate.update("txzldp.collectMaintenance.updateQuestionNumList", param));
    }
	
	@PostMapping("deleteQuestionNumList")
    @ApiOperation(value = "", notes = "")
    @ApiImplicitParams({
    })
    public Resp deleteQuestionNumList(
    		@RequestBody(required = false) Map<String,String> param
    		){
		return Resp.success(this.sqlSessionTemplate.update("txzldp.collectMaintenance.deleteQuestionNumList", param));
    }
	
	
	@GetMapping("queryAjxx")
    @ApiOperation(value = "", notes = "")
    @ApiImplicitParams({
    })
    public Resp queryAjxx(
    		@RequestParam(required = false) Map<String,String> param
    		){
		return Resp.success(this.sqlSessionTemplate.selectList("txzldp.collectMaintenance.queryAjxx", param));
    }
	
	@PostMapping("insertAjxx")
    @ApiOperation(value = "", notes = "")
    @ApiImplicitParams({
    })
    public Resp insertAjxx(
    		@RequestBody(required = false) Map<String,String> param
    		){
		int num = this.sqlSessionTemplate.insert("txzldp.collectMaintenance.insertAjxx", param);
		if(num == 0) {
			return Resp.error("年份重复");
		}else {
			return Resp.success(num);
		}
    }
	
	@PostMapping("updateAjxx")
    @ApiOperation(value = "", notes = "")
    @ApiImplicitParams({
    })
    public Resp updateAjxx(
    		@RequestBody(required = false) Map<String,String> param
    		){
		return Resp.success(this.sqlSessionTemplate.update("txzldp.collectMaintenance.updateAjxx", param));
    }
	
	@PostMapping("deleteAjxx")
    @ApiOperation(value = "", notes = "")
    @ApiImplicitParams({
    })
    public Resp deleteAjxx(
    		@RequestBody(required = false) Map<String,String> param
    		){
		return Resp.success(this.sqlSessionTemplate.update("txzldp.collectMaintenance.deleteAjxx", param));
    }
	
}